#!/opt/local/bin/perl

unless (open (A, @ARGV[0])) {
    die ("cannot open input file file1\n");
}
unless (open (B, @ARGV[1])) {
        die ("cannot open input file file2\n");
}
@array = <B>;
close(B);

open(F,">tmp") || die "cannot open output file: $!";
print F "\n";
$i=0;
$skip=0;
while (1) {
    if (!$skip) {
       if ($line=<A>) {
       } else {
           last;
       }
    }
    $skip=0;
    if ($line=~/msgid \"\"/) {
       while ($line=<A>) {
           if ($line=~/msgid \"/) {
                last;
            }
        }
        $skip=1;
#        print F $line;
        next;
    }
    if ($line=~/msgid \"/) {
        for ($i=0; $i<@array+0; $i++) {
            if (@array[$i] eq $line){
                  do {
#                    print F @array[$i];
                    $i++;
                  } until ($i>=@array+0 || @array[$i] =~ /msgid \"/);
                  while ($line=<A>) {
                      if ($line=~/msgid \"/) {
                         last;
                      }
                  }
                  $skip=1;
                  last;
            }
        }    
    }
    if (! $skip) {
        print F $line;
    }
}
close(F);
close(A);
